﻿using System;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;

namespace Vaffanculo.Presentation.Component.WizardControl
{
    /// <summary>
    /// Interaction logic for CancelDialog.xaml
    /// </summary>
    public partial class CancelDialog: Window
    {
        public CancelDialog(String title)
        {
            InitializeComponent();
            Title = title;
        }

        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            try
            {
                // Obtain the window handle for WPF application
                IntPtr mainWindowPtr = new WindowInteropHelper(this).Handle;
                HwndSource mainWindowSrc = HwndSource.FromHwnd(mainWindowPtr);
                mainWindowSrc.CompositionTarget.BackgroundColor = Color.FromArgb(0, 0, 0, 0);

                // Get System Dpi
                System.Drawing.Graphics desktop = System.Drawing.Graphics.FromHwnd(mainWindowPtr);
                float desktopDpiX = desktop.DpiX;
                float desktopDpiY = desktop.DpiY;

                // Set Margins
                var margins = new NonClientRegionApi.Margins
                                  {
                                      cxLeftWidth = Convert.ToInt32(5*(desktopDpiX/96)),
                                      cxRightWidth = Convert.ToInt32(5*(desktopDpiX/96)),
                                      cyTopHeight = Convert.ToInt32((75 + 5)*(desktopDpiX/96)),
                                      cyBottomHeight = Convert.ToInt32((5 - 10)*(desktopDpiX/96))
                                  };

               
                int hr = NonClientRegionApi.DwmExtendFrameIntoClientArea(mainWindowSrc.Handle, ref margins);
               


                masterGrid.Background = new SolidColorBrush(Color.FromArgb(128, 255, 255, 255));
            }
            catch (DllNotFoundException)
            {
                Application.Current.MainWindow.Background = Brushes.WhiteSmoke;
            }
        }
    }
}
